const server = require("../controller/server.js");

module.exports = function (app) {
  app.get("/", (req, res) => {
    res.send("你好");
  });

  //   验证是否注册
  app.post("/isRegister", (req, res) => {
    server.isRegister(req, res);
  });

  //管理员注册
  app.post("/register", (req, res) => {
    server.insertUser(req, res);
  });

  //管理员登录
  app.post("/signin", (req, res) => {
    server.signin(req, res);
  });

  //获取评论
  app.post("/comment", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getComment(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });
  // 将评论变为已读
  app.post("/commentIsread", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.commentIsread(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  // 删除评论
  app.post("/deleteComment", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteComment(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  // 获取私信message
  app.post("/message", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getMessage(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  // 获取私信未读数noreadMessage
  app.post("/noreadMessage", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.noreadMessage(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  // 删除私信deleteMessage
  app.post("/deleteMessage", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteMessage(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  

  //获取文章
  app.post("/article", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getArticle(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //修改文章发布状态
  app.post("/changeArticleState", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.changeArticleState(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //文章删除
  app.post("/deleteArticle", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteArticle(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //文章不同状态条数
  app.post("/articleState", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.articleState(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //查找分组exports.subset
  app.post("/subset", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.subset(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //新建分组addSubset
  app.post("/addSubset", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.addSubset(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //修改分组名称updateSubset
  app.post("/updateSubset", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.updateSubset(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //删除分组deleteSubset
  app.post("/deleteSubset", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteSubset(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //获取标签getLabel
  app.post("/label", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getLabel(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });
  //新建标签addLabel
  app.post("/addLabel", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.addLabel(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //删除标签deleteLabel
  app.post("/deleteLabel", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteLabel(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //获取文件getFile
  app.post("/file", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getFile(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //移动文件removeFile
  app.post("/removeFile", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.removeFile(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //获取日记
  app.post("/diary", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.getDiaryPage(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //删除日记deleteDiary
  app.post("/deleteDiary", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteDiary(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });
  //新建文章/图库
  app.post("/createArticle", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.createArticle(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //获取文章gainArticle
  app.post("/gainArticle", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.gainArticle(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });
  //修改文章/图库updateArticle
  app.post("/updateArticle", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.updateArticle(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //新建日记createDiary
  app.post("/createDiary", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.createDiary(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //删除文件deleteFile
  app.post("/deleteFile", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.deleteFile(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });

  //获取数据总览overview
  app.post("/overview", (req, res) => {
    if (typeof req.body.token != 'undefined') {
      server.overview(req, res);
    } else {
      res.send({
        code: 400,
      });
    }
  });
};
